package com.example.clock.entity;

public class ResultInfo<T> {
    private Integer code;

    private String msg;

    private T data;

    public ResultInfo(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResultInfo() {
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static <U> ResultInfo<U> success(U data){
        return new ResultInfo<>(200,"成功",data);
    }
    public static <U> ResultInfo<U> success(String msg){
        return new ResultInfo<>(200,msg,null);
    }
    public static <U> ResultInfo<U> success(){
        return new ResultInfo<>(200,"成功！",null);
    }
    public static <U> ResultInfo<U> fail(String msg){
        return new ResultInfo<>(500,msg,null);
    }
    public static <U> ResultInfo<U> fail(){
        return new ResultInfo<>(500,"失败！",null);
    }
}
